package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.dao.IOrdersDao;
import com.itheima.domain.Orders;
import com.itheima.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersServiceImpl implements IOrdersService {

    @Autowired
    private IOrdersDao ordersDao;


    /**
     * 分页查询，查询所有订单信息
     *
     * @param pageNum  当前页
     * @param pageSize 每页显示条数
     * @return
     */
    @Override
    public List<Orders> findAllOrders(Integer pageNum, Integer pageSize) {
        //调用分页查询插件
        PageHelper.startPage(pageNum, pageSize);
        return ordersDao.findAllOrders();
    }

    /**
     * 根据订单id，查询订单详情
     *
     * @param ordersId 订单ID
     * @return
     */
    @Override
    public Orders findByOrdersId(String ordersId) {
        return ordersDao.findByOrdersId(ordersId);
    }
}
